package com.biscuit.page.basicservice.model.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author mazihao
 * @createTime 2024/4/1 17:14
 */
@Getter
public enum ImageFileContentTypeEnum {

    IMAGE_1(".jpg", "image/jpeg"),
    IMAGE_2(".jpeg", "image/jpeg"),
    IMAGE_3(".png", "image/png"),
    IMAGE_4(".gif", "image/gif"),
    IMAGE_5(".bmp", "image/bmp"),
    IMAGE_6(".tiff", "image/tiff"),
    IMAGE_7(".webp", "image/webp"),
    IMAGE_8(".heif", "image/heif"),
    IMAGE_9(".svg", "image/svg+xml"),
    IMAGE_10(".icon", "image/x-icon"),
    IMAGE_11(".psd", "image/vnd.adobe.photoshop"),
    IMAGE_12(".raw", "image/x-raw"),
    IMAGE_13(".eps", "application/postscript"),
    IMAGE_14(".hdr", "image/vnd.radiance");

    private final String type;

    private final String content;

    ImageFileContentTypeEnum(String type, String content) {
        this.type = type;
        this.content = content;
    }

    public static ImageFileContentTypeEnum getImageContentTypeBySuffix(String suffix) {
        return Arrays.stream(ImageFileContentTypeEnum.values())
                .filter(x -> x.type.contains(suffix.toLowerCase()))
                .findFirst()
                .orElse(null);
    }

}
